package com.baosu.test;

import com.baosu.reggie.dto.DishDto;
import com.baosu.reggie.entity.Dish;
import com.baosu.reggie.entity.Employee;
import org.springframework.beans.BeanUtils;

public class Copy {
    public static void main(String[] args) {
        Dish dish = new Dish();
        dish.setId(1L);
        dish.setCategoryId(22L);
        dish.setName("测试");

        DishDto dishDto = new DishDto();

        System.out.println(dish.toString());
        System.out.println(dishDto.getName());  //null

        BeanUtils.copyProperties(dish,dishDto,"id");
        System.out.println(dishDto.getName());  //测试
        System.out.println(dishDto.getId());  //null
        System.out.println(dishDto.getCategoryId());  //22

        Employee employee = new Employee();
        BeanUtils.copyProperties(dish,employee);

        System.out.println(employee.getId());


    }
}
